|
|
|
|
|
|
|
The most common type of constants youll create are public in scope. The reason is that constants are normally used throughout your entire application. To declare a public constant, use code that looks similar to the following: |
|
|
|
 |
|
|
|
|
Public Const gconERR_MSG As String = "This value is in Error" |
|
|
|
|
|
|
|
|
You can now use this public constant, gconERR_MSG, in any procedure in your entire application. |
|
|
|
|
| Global Constant Example 1. Look in the Vars.bas file to view the aforementioned declaration. 2. Double-click the Global Const command button to view the following code, which uses the public constant: | | Private Sub cmdConst_Click ()
lblConst.Caption = gconERR_MSG
End Sub |  | Global constants are the ones you will use most often. These are easy to use all over your application and easy to change. |
|
|
|
|
|
|
Visual Basic has many other built-in constants that youll learn about as you use more of the built-in functions in Visual Basic. Many of the custom controls and DLLs youll use also have their set of built-in constants. Most of the Visual Basic constants start with the prefix vb. Other DLLs have their own prefixes. |
|
|
|
|
|
|
|
|
Mathematical and Relational Operators |
|
|
|
|
|
|
|
|
Any programming language has a set of symbols that allow you to perform a mathematical or relational operation on two or more operands. These symbols are called mathematical and relational operators. Visual Basic has a rich set of these operators. Here are some examples: |
|
|
|
|
|